package org.cdivtc.exam.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class ResponsePojo<T> {
    @ApiModelProperty(value = "响应的数据")
    private T data;
    @ApiModelProperty(value = "响应的说明信息")
    private String message;
    @ApiModelProperty(value = "响应状态码，1 成功， 2 失败")
    private int code;/*成功 1，失败 2*/

    private ResponsePojo(T t){
        this.data = t;
        this.code = 1;
        this.message = "";
    }

    public T getData() {
        return data;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(T data) {
        this.data = data;
    }


    public ResponsePojo(T t, String message, int code){
        this.data = t;
        this.code = code;
        this.message = message;
    }
    public static <T>ResponsePojo<T> success(T t){
        return new ResponsePojo(t);
    }
    public static <T>ResponsePojo<T> fail(T t,String message){
        return new ResponsePojo(t,message,2);
    }
}
